Skip to main content

Rect Class

Description:

  A class for creating rectangle objects.

zero

Type: Readonly Field.

Description:

  A rectangle object with all properties set to 0.

Signature:

const zero: Rect

__call

Type: Metamethod.

Description:

  Create a new rectangle object using another rectangle object.

Signature:

metamethod __call: function(self: RectClass, other: Rect): Rect

Parameters:

ParameterTypeDescription
otherRectThe other rectangle object to create a new rectangle object from.

Returns:

Return TypeDescription
RectA new rectangle object.

__call

Type: Metamethod.

Description:

  Create a new rectangle object using individual properties.

Signature:

metamethod __call: function(self: RectClass,
x: number,
y: number,
width: number,
height: number): Rect

Parameters:

ParameterTypeDescription
xnumberThe x-coordinate of the origin of the rectangle.
ynumberThe y-coordinate of the origin of the rectangle.
widthnumberThe width of the rectangle.
heightnumberThe height of the rectangle.

Returns:

Return TypeDescription
RectA new rectangle object.

__call

Type: Metamethod.

Description:

  Create a new rectangle object using a Vec2 object for the origin and a Size object for the size.

Signature:

metamethod __call: function(self: RectClass, origin: Vec2, size: Size): Rect

Parameters:

ParameterTypeDescription
originVec2The origin of the rectangle, represented by a Vec2 object.
sizeSizeThe size of the rectangle, represented by a Size object.

Returns:

Return TypeDescription
RectA new rectangle object.

__call

Type: Metamethod.

Description:

  Create a new rectangle object with all properties set to 0.

Signature:

metamethod __call: function(self: RectClass): Rect

Returns:

Return TypeDescription
RectA new rectangle object.